using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Ent.Voice.Show;
using Ent.Web;
using Ent.Web.Helper;
public partial class Default : System.Web.UI.Page
{
    private Settings _set;
    private int _catId = -1;
    public Default()
    {
        this.PreRender += new EventHandler(Default_PreRender);
    }

    void Default_PreRender(object sender, EventArgs e)
    {
        lblCatagory.Text = ResourceHelper.Get("LBL_Catagory");
        imgFirstMore.Attributes.Add("onmouseover", "this.src='Images/dj/nexth.gif'");
        imgFirstMore.Attributes.Add("onmouseout", "this.src='Images/dj/next.gif'");
        imgSecondMore.Attributes.Add("onmouseover", "this.src='Images/dj/nexth.gif'");
        imgSecondMore.Attributes.Add("onmouseout", "this.src='Images/dj/next.gif'");
        imgThirdMore.Attributes.Add("onmouseover", "this.src='Images/dj/nexth.gif'");
        imgThirdMore.Attributes.Add("onmouseout", "this.src='Images/dj/next.gif'");
    }
    private void SetControls()
    {
        if (!IsPostBack)
        {
            _set = new Settings(Server.MapPath("Data/Settings.xml"));
            ddlCatagory.Items.AddRange(_set.GetItemCollection("Catagory", new ListItem[] { new ListItem("All", "-1") }));
            ((Controls_Updates)this.Master.FindControl("cUpdates")).CatagoryId = _catId;
            ddlCatagory.SelectedIndex = ddlCatagory.Items.IndexOf(ddlCatagory.Items.FindByValue(_catId.ToString()));
        }
        Event[] evs = Event.GetPopularTopNEvent(3, _catId, 5, false, StringHelper.ConvertToString(Session["USERID"]));
        if (evs == null)
        {
            lblMessage.Text += "&nbsp;&nbsp;" + Common.GetErrorText(ResourceHelper.Get("MSG_NoEvent"));
            lblMessage.Visible = true;
            return;
        }
        Event ev = null;
        if (evs.Length > 0)
        {
            ev = (Event)evs.GetValue(0);
            if (ev != null)
            {
                TransTable1.Visible = true;
                imgFirstMore.Visible = true;
                topEvent.Event = ev;
                TransTable1.Visible = true;
                imgFirstMore.Visible = true;
                imgFirstMore.Attributes.Add("onclick", "javascript:window.location.href='ShowEvent.aspx?id=" + ev.Id + "'");
            }
          
        }
        if (evs.Length > 1)
        {
            ev = (Event)evs.GetValue(1);
            if (ev != null)
            {
                TransTable2.Visible = true;
                imgSecondMore.Visible = true;
                secondEvent.Event = ev;
                TransTable2.Visible = true;
                imgSecondMore.Visible = true;
                imgSecondMore.Attributes.Add("onclick", "javascript:window.location.href='ShowEvent.aspx?id=" + ev.Id + "'");
            }
        }
        if (evs.Length > 2)
        {
            ev = (Event)evs.GetValue(2);
            if (ev != null)
            {
                TransTable3.Visible = true;
                imgThirdMore.Visible = true;
                thirdEvent.Event = ev;
                TransTable3.Visible = true;
                imgThirdMore.Visible = true;
                imgThirdMore.Attributes.Add("onclick", "javascript:window.location.href='ShowEvent.aspx?id=" + ev.Id + "'");
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["cat"] != null)
            _catId = Ent.Web.Helper.MathFunction.ConvertToInteger(Request.QueryString["cat"]);
        SetControls();
    }
}
